/* GMRobot.cc -- Representação de um robo
 *
 * Copyright (C) 2008, Diogo F. S. Ramos <diogo.ramos@usp.br>
 * GEAR - Grupo de Estudos Avançados em Robótica
 * <http://www.sel.eesc.usp.br/gear>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include <string>
#include <vector>

#include "gm_protocol.h"
#include "GMRobot.hh"

GMRobot::GMRobot( const int id,
		  const std::string end,
		  const std::string addr,
		  const int port )
{
    robot = gm_robot_new( id, end.c_str(), addr.c_str(), port);
    field = std::vector<float>( LENGTH_FIELD_VECTOR, 0.0);
    world = std::vector<float>( LENGTH_WORLD_VECTOR, 0.0);
}

GMRobot::~GMRobot()
{
    gm_robot_destroy( robot );
}

void
GMRobot::Read()
{
    int i = 0;
    
    gm_robot_read( robot );

    for( i = 0 ; i < LENGTH_FIELD_VECTOR ; i++ )
    {
	field[i] = robot->info[i];
    }
}

void
GMRobot::ReadWorld()
{
    int i = 0;
    
    gm_robot_read_world( robot );

    for( i = 0 ; i < LENGTH_WORLD_VECTOR ; i++ )
    {
	world[i] = robot->world[i];
    }
}

void
GMRobot::SetVel( const float vx, const float vy, const float va)
{
    gm_robot_set_vel( robot, vx, vy, va );
}

void
GMRobot::DribbleEnable( const int enable )
{
    gm_robot_dribble_enable( robot, enable );
}

void
GMRobot::Kick( const int nivel )
{
    gm_robot_kick( robot, nivel );
}

void
GMRobot::SayHello()
{
    gm_robot_say_hello( robot );
}
